package Exercise01;

import java.util.Scanner;

public class test01 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Person person[] =new Person[3];
        person[0] = new Person("jack",12,"java工程师");
        person[1] = new Person("lihua",15,"软件工程");
        person[2] = new Person("hubiao",22,"扫地");

        for (int i = 0;i<person.length;i++){
            System.out.println(person[i]);
        }

        for(int i = 0;i< person.length-1;i++){
            for (int j = 0;j< person.length-i-1;j++){

                if(person[j].getAge() < person[j+1].getAge()){
                    Person tmp = person[j];
                    person[j] = person[j+1];
                    person[j+1] = tmp;
                }
            }

            }
        System.out.println("===========交换后===========");
        for (int  i = 0;i<person.length;i++){
            System.out.println(person[i]);


        }

    }


}


class Person{
    private String name;
    private int age;
    private String job;

    public Person(String name, int age, String job) {
        this.name = name;
        this.age = age;
        this.job = job;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", job='" + job + '\'' +
                '}';
    }
}
